using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using MetroControl;
using DevComponents.DotNetBar.Metro;

namespace MyVideo
{
    public partial class FrmMain : DevComponents.DotNetBar.Metro.MetroAppForm
    {
        PlayMusic playMusic;
        PlayVideo playVideo;
        BulidRingSound bulidRingSound;
        RecordSound recordSound;
        ReadEnglish readEnglish;
        public FrmMain()
        {
            InitializeComponent();
            readEnglish = new ReadEnglish();
            metroTabPanel2.Controls.Add(readEnglish);
            playMusic = new PlayMusic();
            metroTabPanel3.Controls.Add(playMusic);
            playVideo = new PlayVideo();
            metroTabPanel4.Controls.Add(playVideo);
            bulidRingSound = new BulidRingSound();
            metroTabPanel5.Controls.Add(bulidRingSound);
            recordSound = new RecordSound();
            metroTabPanel6.Controls.Add(recordSound);
            UpdateControlsSizeAndLocation();
        }

        private void metroShell1_HelpButtonClick(object sender, EventArgs e)
        {
            HelpControlClass helpControlClass = new HelpControlClass(this);
            helpControlClass.OpenControl();
        }

        private void metroShell1_SettingsButtonClick(object sender, EventArgs e)
        {
            SettingControlClass settingControlClass = new SettingControlClass(this);
            settingControlClass.OpenControl();
        }

        private Rectangle GetStartControlBounds()
        {
            int captionHeight = metroShell1.MetroTabStrip.GetCaptionHeight() + 2;
            Thickness borderThickness = this.GetBorderThickness();
            return new Rectangle((int)borderThickness.Left, captionHeight, this.Width - (int)borderThickness.Horizontal, this.Height - captionHeight - 1);
        }

        protected override void OnResize(EventArgs e)
        {
            UpdateControlsSizeAndLocation();
            base.OnResize(e);
        }

        private void UpdateControlsSizeAndLocation()
        {
            Rectangle rectangle = GetStartControlBounds();
            if (recordSound != null)
            {
                recordSound.Bounds = rectangle;
            }
            if (playVideo != null)
            {
                playVideo.Bounds = rectangle;
            }
            if (playMusic != null)
            {
                playMusic.Bounds = rectangle;
            }
            if (bulidRingSound != null)
            {
                bulidRingSound.Bounds = rectangle;
            }
            if (readEnglish != null)
            {
                readEnglish.Bounds = rectangle;
            }
        }
    }
}